package com.partners.handler;

import com.partners.service.FansService;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author Binary Wang(https://github.com/binarywang)
 */
@Component
public  class ScanHandler extends AbstractHandler {

    @Resource
    private FansService fansService;

    @Override
    public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
                                    Map<String, Object> context, WxMpService wxMpService,
                                    WxSessionManager sessionManager){

        String sceneStr = "";
        if(wxMessage.getEvent().equals("SCAN")){
            sceneStr = wxMessage.getEventKey();
            fansService.getSceneStr(sceneStr);
        }

        //this.logger.info("\n扫码后的内容：{}", JsonUtils.toJson(wxMessage));
        return null;
    }
}
